<template>
  <div>
    <ul v-if="consultationList.length" class="consultation-order clearfix">
      <li v-for="(item, index) in consultationList" :key="index" class="page-consultation consultation-warning float-left">
        <div class="consultation-info">
          <img :src="item.mavatarImg ? item.mavatarImg : 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3448484253,3685836170&amp;fm=27&amp;gp=0.jpg'">
          <span class="consultation-title">{{item.title}}</span>
          <span class="consultation-name">{{item.mname}}</span>
          <span class="consultation-no">问题编号：{{item.id}}</span>
          <div class="consultation-accpet">
            <el-button type="primary" size="mini" @click="accpetIMText(item)">接诊</el-button>
          </div>
        </div>
        <div class="consultation-des">{{item.description}}</div>
        <div class="consultation-info margin-bottom-10">
          <el-tag v-for="(value, index) in item.consultationType" :key="index" class="consultation-tag" size="mini" type="danger">{{value}}</el-tag>
          <span class="consultation-time"><i class="el-icon-time"></i> {{item.created_at}}</span>
        </div>
      </li>      
    </ul>
    <div class="no-order" v-else>
      <i class="el-icon-document"></i>
      <p>暂无信息</p>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      consultationList: []
    }
  },
  mounted() {    
    this.getConsultationListData();
  },
  methods: {
    getConsultationListData() {
      let id = this.$store.state.doctorInfo.id;
      this.axios.get('/doctor/' + id + '/consultations/list/text/10/1').then((response) => {
        if(response.data.code == 200){
          this.consultationList = response.data.data.data;
        }else{
          this.$message({
            message: '数据加载失败!',
            type: 'error'
          });
        }
      });
    },
    accpetIMText(item) {        
      this.$router.push({ name: 'ReferralInfo', params: {consultationId:item.id} });
    }
  }
}
</script>
